package com.api.phm.service.impl;

import com.api.phm.domain.model.FaultLogModel;
import com.api.phm.domain.query.FaultLogPageQuery;
import com.api.phm.domain.vo.FaultLogVo;
import com.api.phm.mapper.FaultLogMapper;
import com.api.phm.service.IFaultLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FaultLogServiceImpl implements IFaultLogService {
    @Autowired
    private FaultLogMapper faultLogMapper;

    @Override
    public List<FaultLogPageQuery> searchFaultLogList(FaultLogVo faultLogVo) {
        List<FaultLogPageQuery> list = faultLogMapper.searchFaultLogList(faultLogVo);
        for (FaultLogPageQuery faultLogPageQuery : list) {
            try {
                faultLogPageQuery.initLabelValue();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return list;
//        return faultLogMapper.searchFaultLogList(faultLogVo);
    }

    @Override
    public void readFaultLogMessage(String faultId) throws Exception {
        faultLogMapper.readFaultLogMessage(faultId);
    }

    @Override
    public void insertFaultLog(FaultLogModel logModel) {
        faultLogMapper.insertFaultLog(logModel);
    }

    @Override
    public void addFaultLogList(List<FaultLogModel> list) {
        faultLogMapper.addFaultLogList(list);
    }
}
